<include file="Public:head" title='服务详情' />
<script src="__PUBLIC__/js/other/validate.js"></script>
<script src="__PUBLIC__/js/plugins/kind2/kindeditor-min.js"></script>
<script>
    $(function() {
        // $.getScript("__PUBLIC__/js/plugins/kind2/kindeditor-min.js", function() {
        //     KindEditor.basePath = '__PUBLIC__/js/plugins/kind2/';
        //     KindEditor.create('textarea[id="content_goods"]');
        // });
        KindEditor.ready(function(K) {
            window.editor = K.create('#content_goods', {
                items: [
                    'source', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
                    'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                    'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                    'superscript', 'clearhtml', 'quickformat', 'selectall', '|', '/',
                    'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                    'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',
                    'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
                    'anchor', 'link', 'unlink', '|'
                ]
            })
        });

        KindEditor.ready(function(K) {
            window.editor = K.create('#content_cases', {
                items: [
                    'source', '|',  'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
                    'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                    'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                    'superscript', 'clearhtml', 'quickformat', 'selectall', '|', '/',
                    'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                    'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',
                    'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
                    'anchor', 'link', 'unlink', '|'
                ]
            })
        });
    })


</script>
<div class="main-container" id="main-container">
    <div class="main-container-inner">
        <include file="Public:left" />
        <div class="main-content">
            <div class="breadcrumbs" id="breadcrumbs">
                <ul class="breadcrumb">
                    <li><i class="icon-home home-icon"></i><a href="__APP__/{$Think.MODULE_NAME}">首页</a></li>
                    <li><a href="{:U('Service/lists')}">服务管理</a></li>
                    <li class="active">服务列表</li>
                </ul>
            </div>
            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="row">
                            <div class="col-xs-12">
                                <h3 class="header smaller lighter blue">服务{$Think.get.id|getPageType}</h3>
                                <form id="form" enctype="multipart/form-data" method="POST" action="{:U('Service/detail_post')}" onsubmit="return checkJsForm()" data-id="{$detail.id}">
                                    <div class="caption">
                                        <table class="table table_detail">
                                            <tr>
                                                <td class="td_left">标题</td>
                                                <td>
                                                    <input type="text" value="{$detail.title}" name="title" id="name" autocomplete="off"/>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="td_left">分类</td>
                                                <td>
                                                    <notempty name="detail">
                                                    <foreach name="cats" item="row" key="k">
                                                        <label class='label_width'>
                                                            <input type='radio' value='{$row.id}' class="cat_sub_id" name='cat_id' autocomplete="off" <if condition="$detail.cat_id eq $row.id" >checked="checked" </if> {$detail.cat_id|getChecked=###,$row[id]}>
                                                            {$row.name}
                                                        </label>
                                                    </foreach>
                                                        <else/>
                                                        <foreach name="cats" item="row" key="k">
                                                            <label class='label_width'>
                                                                <input type='radio' value='{$row.id}' class="cat_sub_id" name='cat_id' autocomplete="off" <if condition="$k eq 0" >checked="checked" </if> {$detail.cat_id|getChecked=###,$row[id]}>
                                                                {$row.name}
                                                            </label>
                                                        </foreach>
                                                    </notempty>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="td_left">上传封面图</td>
                                                <td>
                                                    <a id="big_img_area">

                                                        <if condition="$detail.logo neq ''">
                                                            <div class="progress" id="o_1cn1h7vqra818bo1jisct414sa9">
                                                                <input type="hidden" name="logo_big" value="{$detail.logo}">
                                                                <img src="__APP__/{$detail.logo}" class="img_common" alt="封面图" class="cover_img" id="cover_img"/>
                                                            </div>
                                                            <else/>
                                                            <img src="__PUBLIC__/images/cover.jpg" alt="封面图" class="cover_img" id="cover_img"/>
                                                        </if>
                                                    </a>
                                                    <a class="cover_btn" id="cover_btn_big_faq"><span>+</span></a>
                                                    <span class="tip" style="margin:30px 0 0;display: inline-block">建议760*980px的图片。宽高不限</span>
                                                </td>
                                            </tr>
                                        <tr>
                                            <td class="td_left">来源</td>
                                            <td>
                                                <input type="text" value="{$detail.source}" placeholder="http://www.sucaihuo.com" name="source" autocomplete="off"/>
                                                <span class="tip">链接地址如：“http://www.sucaihuo.com”</span>  
                                            </td>
                                        </tr>

                                        <tr>
                                            <td class="td_left">状态</td>
                                            <td>

                                                <label>
                                                    <input class="ace" type="radio"  name="is_check" value='0' {$detail.is_check|getEqual=###,0,'checked'} autocomplete='off'/>
                                                    <span class="lbl"> 关闭</span>
                                                </label>
                                                <label>
                                                    <input class="ace" type="radio"  name="is_check" value='1' {$detail.is_check|getEqual=###,1,'checked'} autocomplete='off'/>
                                                    <span class="lbl"> 开启</span>
                                                </label>
                                            </td>
                                        </tr>

                                        <tr>
                                            <td class="td_left">关键字</td>
                                            <td>
                                                <textarea class="textarea" name="keywords" id="keywords" autocomplete="off">{$detail.keywords}</textarea>
                                            </td>
                                        </tr>

                                        <tr>
                                             <td class="td_left">描述</td>
                                             <td>
                                                 <textarea class="textarea" name="description" id="description" autocomplete="off">{$detail.description}</textarea>
                                             </td>
                                        </tr>

                                         <tr>
                                                <td class="td_left">常见问题</td>
                                                <td>
                                                    <div class="faqbox">
                                                    <notempty name="content_problems">
                                                         <foreach name="content_problems" item="row" key="k">
                                                             <div class="faqlist">
                                                                  <input type="text" name="faq[{$k}][faqProblem]" value="{$row.faqProblem}" class="faqProblem"  ><br/>
                                                                  <textarea class="faqAnswer" name="faq[{$k}][faqAnswer]"  style="min-height: 80px; width: 560px;" autocomplete="off">{$row.faqAnswer}</textarea>
                                                              </div>
                                                         </foreach>
                                                        <else/>
                                                              <div class="faqlist">
                                                                  <input type="text" name="faq[0][faqProblem]" placeholder="请填写问题的标题" class="faqProblem"  ><br/>
                                                                  <textarea class="faqAnswer" name="faq[0][faqAnswer]" placeholder="请填写问题的解决方案"   style="min-height: 80px; width: 560px;"  autocomplete="off">{$detail.keywords}</textarea>
                                                              </div>
                                                    </notempty>
                                                    </div>
                                                    <div class="addfaq" ><span onclick="addfaq()" style="cursor: pointer;font-size: 20px;color: #00b33b">添加</span><span onclick="removefaq()" style="cursor: pointer;font-size: 20px;color: #b30009;margin-left: 30px">删除</span></div>
                                                </td>
                                            </tr>

                                  <script>
                                    function addfaq() {
                                      var faqCount = $(".faqlist").length;
                                      var faqCount = faqCount + 1;
                                      var htm =  ' <div class="faqlist">';
                                        htm +=  '<input type="text" name="faq['+faqCount+'][faqProblem]" placeholder="请填写问题的标题" class="faqProblem"  ><br/>';
                                        htm +=  '<textarea class="faqAnswer" name="faq['+faqCount+'][faqAnswer]"  placeholder="请填写问题的解决方案"   style="min-height: 80px; width: 560px;"  autocomplete="off"></textarea>';
                                        htm +=  '</div>';
                                        $(".faqbox").append(htm);
                                    }

                                    function removefaq() {
                                        var faqCount = $(".faqlist").length;
                                        var faqCount = faqCount + 1;
                                        $('.faqbox').children(".faqlist:last").remove();
                                    }
                                  </script>

                                        <tr>
                                            <td class="td_left">产品参数</td>
                                            <td>
                                                <textarea class="textarea" name="content_goods" id="content_goods" autocomplete="off" style="height:300px">{$detail.content_goods}</textarea>
                                            </td>
                                        </tr>

                                        <tr>
                                            <td class="td_left">案例/演示</td>
                                            <td>
                                                <textarea class="textarea" name="content_cases" id="content_cases" autocomplete="off" style="height:300px">{$detail.content_cases}</textarea>
                                            </td>
                                        </tr>

                                        <tr>
                                            <td class="td_left"></td>
                                            <td>
                                                <input type='hidden' name='id' value='{$Think.get.id}'/>
                                                <button class="btn btn-info btn-sm" type="submit">
                                                    <i class="icon-ok bigger-110 "></i>
                                                    保 存
                                                </button>
                                                <button class="btn btn-sm reset" type="button" onclick="goUrl(-1)">
                                                    <i class="icon-undo bigger-110"></i>
                                                    返 回
                                                </button>
                                            </td>
                                        </tr>
                                        </table>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <include file="Public:setting" />
    </div>
</div>

<include file="Public:foot" />
<div class="modal fade" id="modal_cat" data-id="0" data-modal="position"  tabindex="-1" role="dialog" aria-labelledby="modal_catLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" ></h4>
            </div>
            <div class="modal-body">
                名称：
                <input id="cat_name" type="text" class="common_txt" value="{$detail.ord}" maxlength="20" autocomplete="off"/>
            </div>
            <div class="modal-footer">
                <button class="btn btn-danger btn-xs ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="submit" role="button" aria-disabled="false" >
                    <span class="ui-button-text">
                        <i class="icon-trash bigger-110"></i>
                        确 定
                    </span>
                </button>
                <button class="btn btn-xs ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false" data-dismiss="modal">
                    <span class="ui-button-text">
                        <i class="icon-remove bigger-110"></i>
                        取 消
                    </span>
                </button>

            </div>
        </div>
    </div>
</div>


<include file="Uploads:plupload" />
<link rel="stylesheet" href="__PUBLIC__/css/uploads.css" type="text/css" /> 
<!--<script type="text/javascript" src="__APP__/other/js/uploads.js"></script>-->
<script>
    var uploader3 = new plupload.Uploader({
        runtimes: 'html5,flash,silverlight,html4', //上传插件初始化选用那种方式的优先级顺序
        browse_button: ['cover_btn_big_faq'], // 上传按钮
        url: "http://www.sucai_houtai.com/Tian/Uploadreal/cover_img", //远程上传地址
        flash_swf_url: 'plupload/Moxie.swf', //flash文件地址
        silverlight_xap_url: 'plupload/Moxie.xap', //silverlight文件地址
        filters: {
            max_file_size: '50mb', //最大上传文件大小（格式100b, 10kb, 50mb, 1gb）
            mime_types: [//允许文件上传类型
                {title: "files", extensions: "jpg,png,gif,jpeg"}
            ]
        },
        multi_selection: false, //true:ctrl多文件上传, false 单文件上传
        multipart_params: {
            code: 'identity',
        },
        init: {
            FilesAdded: function(up, files) { //文件上传前

                var item = "";
                plupload.each(files, function(file) { //遍历文件
                    item += "<div class='progress' id=" + file['id'] + "><span class='bar'></span><span class='percent'>0%</span></div>";
                });
                $("#big_img_area").html(item)
                uploader3.start();

            },
            UploadProgress: function(up, file) { //上传中，显示进度条
                var percent = file.percent;
                $("#" + file.id).find('.bar').css({"width": percent + "%"});
                $("#" + file.id).find(".percent").text(percent + "%");
            },
            FileUploaded: function(up, file, info) { //文件上传成功的时候触发
                var data = eval("(" + info.response + ")");//解析返回的json数据
                if (data.error != '') {
                    $("#big_img_area").html("<img id='cover_img' class='cover_img' src='/Public/images/cover.jpg' alt='封面'><input name='logo' value='' autocomplete='off' type='hidden'>");
                } else {
                    // $("#big_img_area").html('');
                    $("#" + file.id).html("<input type='hidden'name='logo_big' value='" + data.src + "'/><img class='img_common'  src='http://www.sucai_houtai.com/" + data.src + "'/>");//追加图片

                }
            },
            Error: function(up, err) { //上传出错的时候触发
                alert(err.message);
            }
        }
    });
    uploader3.init();
</script>


